how to count words in javascript string